import { SubjectComponent } from "../../../../core/subject";

const { ccclass, property } = cc._decorator;

@ccclass
export default class BulletAttrItem extends SubjectComponent {
    @property(cc.Label)
    lbKey: cc.Label = null;
    @property(cc.EditBox)
    ebVal: cc.EditBox = null;

    @property(cc.Node)
    diffNode: cc.Node = null;

    setVal(key: string, val: any) {
        this.lbKey.string = key;
        this.ebVal.string = `${val}`;
        this.diffNode.active = false;
    }
    setValAdditive(key: string, val: any) {
        this.lbKey.string = key;
        if (this.ebVal.string == `${val}`) {
            this.ebVal.string = `${val}`;
            this.diffNode.active = false;
        }
        else {
            this.diffNode.active = true;
        }
    }

    onEdit() {
        this.emit("edit", this.ebVal.string);
    }
};